<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui"
      xmlns:h="http://java.sun.com/jsf/html">

    <h:body>

        <ui:composition template="/resources/template/template.xhtml">

            <ui:define name="content">

                <h:form >


                    <p:panel header="Manage Report Templates" style="height: 100%; width: 98%; min-height: 900px;" >

                        <p:panelGrid columns="4" >
                            <p:outputLabel value="Search a Template" ></p:outputLabel>
                            <p:autoComplete id="acTemplate" 
                                            value="#{investigationItemController.current}" 
                                            completeMethod="#{investigationItemController.completeTemplate}"
                                            var="ii" itemLabel="#{ii.name}" itemValue="#{ii}" >
                                <p:ajax event="itemSelect" process="@this" update="details" ></p:ajax>
                            </p:autoComplete>
                            <p:commandButton id="btnAdd" process="@this" update="details" value="Add New Template" action="#{investigationItemController.newTemplate()}" ></p:commandButton>
                        </p:panelGrid>
                        <h:panelGroup id="details" >
                            <p:panelGrid columns="3" >
                                <p:outputLabel value="Name of the Template" ></p:outputLabel>
                                <p:inputText id="txtName" value="#{investigationItemController.current.name}" rendered="#{investigationItemController.current ne null}" ></p:inputText>
                                <p:commandButton id="btnSave"
                                                 process="details"
                                                 update="@form"
                                                 value="Save Template" action="#{investigationItemController.saveTemplate()}" ></p:commandButton>
                            </p:panelGrid>
                            <p:editor id="editor" value="#{investigationItemController.current.htmltext}" widgetVar="editor" height="650" style="height: 90%;min-height: 650px;"
                                      rendered="#{investigationItemController.current ne null}" ></p:editor>
                           
                        </h:panelGroup>
                        <a href="https://html-online.com/editor/"  target="_blank"  >An external link to remove un-necessary formatings</a>
                    </p:panel>


                </h:form>
            </ui:define>

        </ui:composition>

    </h:body>
</html>
